const express = require('express');
const router = express.Router();
const userController = require('../controllers/userController');
const auth = require('../middlewares/auth');
const { roleAuth } = require('../middlewares/auth');

router.post('/register', userController.register);
router.post('/login', userController.login);
router.get('/profile', auth, userController.profile);
router.get('/all', auth, roleAuth(['admin']), userController.getAllUsers);

// 实时校验手机号和用户名唯一性
router.get('/check-phone', userController.checkPhone);
router.get('/check-username', userController.checkUsername);

module.exports = router; 